package com.nfIt.caiJi;

/**
 * ClossName:Gather
 * Pakage:com.nfIt.caiJi
 * Description
 *
 * @Author L
 * @Create 2024/3/20 15:45
 * @Version 2023.1.3
 */
public class Gather extends Thread{
    @Override
    public void run(){


        while (true){
            //正常执行数据
            System.out.println("采集数据");

            //获取线程状态
            boolean status = Thread.currentThread().isInterrupted();

            if (status){
                System.out.println("做一些处理");
                break;
            }

            try {
                //每两秒执行一次
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                //二次中断，让status变为true
                System.out.println("在睡眠中被中断,实现一些后续处理");

            }


        }
    }
}
